package com.ysd.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.ysd.entity.Statistics;

public interface StatisticsRepository extends JpaRepository<Statistics, Integer> {
	
	//按天查询人数
	@Query(value = "select s.day as 月份,sum(num) as 人数 from statistics s group by s.day",nativeQuery = true)
	List<Object> findByStatisticsByDay();
	
	//按月查询人数
	@Query(value = "SELECT SUM(num), `month` as yue FROM statistics GROUP BY `month`", nativeQuery = true)
	List<Object> findByStatisticsByMonth();
	
	//按年查询人数
	@Query(value = "select year as 月份,sum(num) as 人数 from statistics group by year", nativeQuery = true)
	List<Object> findByStatisticsByYear();
	
	
			
	//按资源室查询人数
	@Query(value = "select rm.name as 资源室,sum(num) as 人数 from statistics s join read_room rm on s.read_room_id = rm.id group by rm.name",nativeQuery = true)
	List<Object> findByStatisticsByName();
			
}
